<?php

use App\Models\Client;
use Illuminate\Database\Seeder;
use App\Models\CallBack;


class CallbackSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        $faker = Faker\Factory::create('zh_CN');

        $m = new CallBack();

        Client::query()
            ->whereNotNull('employee_id')
            ->each(function ($model) use ($faker, $m){
                $posts = factory($m)
                    ->times(1)
                    ->make()
                    ->each(function ($data) use ($model, $faker){
                        $data->client_id = $model->id;
                        $data->employee_id = $model->employee_id;
                        $data->client_name = $model->name;
                    });
                $m->insert($posts->toArray());
            })
        ;



    }
}
